package com.ww.springboot.boot.algorithm.leetcode1;

import java.util.Arrays;

/**
 * 描述：
 *
 * @author 🧑 ‍wanwei
 * @since 2022-04-02 10:01
 */
public class BK1981最小化目标值与所选元素的差 {

    public static void main(String[] args) {

        int[][] mat = {{2, 1, 3}, {4, 5, 6}, {7, 8, 9}};

        System.out.println(minimizeTheDifference(mat, 13));
    }


    /**
     * 重排数组 将数组每行顺序排列
     * 使用回溯
     *
     * @param mat
     * @param target
     * @return
     */
    public static int minimizeTheDifference(int[][] mat, int target) {
        int[][] matNew = new int[mat.length][mat[0].length];

        for (int i = 0; i < mat.length; i++) {
            int[] row = mat[i];
            Arrays.sort(row);
            matNew[i] = row;
        }
        System.out.println(matNew);

        return 0;
    }
}
